<!--#include file="../nav/admin_top.php" --> 
<script type="text/javascript">
var url_save = '<?=url::build('admin','authgroup_modify',array('reqtype'=>'json'))?>'; 
var url_return = '<?=url::build('admin','authgroup')?>'; 
var sysmods = {json_encode($sysmods)};
 

var rs = {json_encode($rs)}; 
var rs_sysmod = {json_encode($rs_sysmod)}; 
 


$().ready(function(){  
	showLoading();  
	window.setInterval(function(){
		$('.innserTb .willctrlighthigh').each(function(){
			var id = $(this).attr('title');
			if($(this).attr('checked')){
				$(this).parent().parent().addClass('hightlight');
			}else{
				$(this).parent().parent().removeClass('hightlight');
			}
		}); 
	},50);
	
	$('#sysmod_ck_all').bind('click',function(){
		if($(this).attr('checked')){
			$('.sysmod_ck').attr('checked','checked');
		}else{
			$('.sysmod_ck').attr('checked','');
		}
	});
  
	
}); 
/* 保存 */
function fnSave(){ 
	var obj_main = {};
	if($('#name').val() == ''){
		alert('请填写权限组名称');
		$('#name').focus();
		return false;
	}
	obj_main['id'] = $('#id').val(); 
	obj_main['name'] = $('#name').val(); 
	obj_main['remark'] = $('#remark').val(); 
	/*   */
	var obj_sysmods = [];
	for(var i=1; i<=sysmods.length; i++){
		if(fnDom('sysmod_ck_'+i) && $('#sysmod_ck_'+i).attr('checked')){ 
			obj_sysmods.push( $('#sysmod_id_'+i).val() );
		}
	} 
  $('button').attr('disabled','disabled');
	$.ajax({
		async:true,
		type:'post',
		url:url_save,
		data:{
			obj_sysmods:JSON.encode(obj_sysmods),
			obj_main:JSON.encode(obj_main)
		},
		success:function(e){
  		$('button').attr('disabled','');
			var ok = errorHandler(e);
			if(ok){　 
				jumpTo(url_return);
			}
		}
	});
}
</script>
<div class="titleDiv">
	<div class="titleCaption">
		<span class="captionSpan">权限组管理 - 修改权限组</span>
		<span class="totalSpan"> <label id="captionNum"></label> </span>
	</div>
</div> 
<div  class="button_div">
		<button class="btn_save" onclick="fnSave()">保 存</button>
		<span class="gray">或</span> 
		<button class=" " onclick="jumpTo(url_return);return false;">返 回</button>
</div> 
<form id="myform" action="" method="post" onsubmit="return false" >
<div class="blockdiv">
	<div class="titlediv">权限组基本信息</div>
	<table class="mytable" >
		<tr>
			<td class="mylabel"><span class="red">*</span>权限组名称：</td>
			<td class="myinfo" >
				<input type="hidden" id="id" name="id" value="{$rs.id}" />
				<input type="text" class="textBox" id="name" name="name" value="{$rs.name}" maxlength="50" style="width:80%" />
			</td>  
		</tr> 
		<tr>
			<td class="mylabel">说明：</td>
			<td class="myinfo" >
				<textarea class="textBox" style="height:35px;width:80%" id="remark" name="remark" >{$rs.remark}</textarea>
			</td>  
		</tr>
	</table> 
</div> 
<table style="width:100%">
	<tr>
		<td style="width:49%;vertical-align:top">
			 
						<div  style="margin:10px auto">后台管理功能权限</div> 
						<table class="innserTb" >
							<thead>
								<tr>
									<th style="width:50px">序号</th>
									<th style="text-align:left ">管理功能</th>
									<th style="text-align:left "><input type="checkbox" id="sysmod_ck_all" title="全选"  /> 是否有权限</th> 
								</tr>
							</thead>
							<tbody id="sysmods"> 
								 <?PHP
								 if(count($sysmods)>0){ 
										$show_index = 1;
										foreach($sysmods as $k=>$sysmod){ 
											echo '<tr id="sysmods_tr_'.$show_index.'" class="sysmods_tr">';
											echo '	<td>'.$show_index.'</td>';
											echo '	<td style="text-align:left ">'.$sysmod['name'].'</td>';
											echo '	<td style="text-align:left "> <input type="hidden" id="sysmod_id_'.$show_index.'" value="'.$sysmod['id'].'"   /> ';
											if(isset($rs_sysmod[$sysmod['id']])){
												echo ' <input type="checkbox" checked="checked" class="willctrlighthigh sysmod_ck "  id="sysmod_ck_'.$show_index.'"   />  ';
											}else{
												echo ' <input type="checkbox" class="willctrlighthigh sysmod_ck "  id="sysmod_ck_'.$show_index.'"   />  ';
											} 
											echo ' </td>';
											echo '</tr>';
											$show_index++;
										}
								 }
								 ?>
							</tbody>
						</table>  
		</td>
	</tr>
</table> 
</form>			
<div  class="button_div">
		<button class="btn_save" onclick="fnSave()">保 存</button>
		<span class="gray">或</span> 
		<button class=" " onclick="jumpTo(url_return);return false;">返 回</button>
</div>  
<!--#include file="../nav/admin_bottom.php" -->